# Force out-of-source build tree - prevent cmake from continuing
# any further if it is being performed in the
# top-level directory.
#
# NOTE Heavy workaround, cmake files must be manually removed
# see http://www.cmake.org/pipermail/cmake/2009-September/031833.html
# and http://www.vtk.org/Bug/view.php?id=6672
#
# Copyright (c) 2009, Maciej "Fazi" Gałkowski <fazi.dev@gmail.com>

if(${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
    message(FATAL_ERROR "
        Please configure and build in a directory other than the 
        top-level source directory. Doing so will prevent files
        distributed with the package from being overwritten.

        For example, try the following from the top-level source
        directory:

            mkdir build
            cd build
            cmake ..
            make

        This will create a build space in the directory 'build' and
        start a build in that directory.

        Remember to remove CMakeCache.txt file and CMakeFiles
        directory (if there is any) from the top-level source
        directory before running commands above.
"
)
    RETURN()
endif(${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
